import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:wallet_utils/report_widget/click_widget.dart';
import '../color.dart';
import '../text_style.dart';

class InfoDialog extends Dialog {
  final VoidCallback? yesCallback;
  final VoidCallback? noCallback;
  final VoidCallback? backCallback;
  final String? content;
  final String? title;
  final String? name;
  final String? yesStr;
  final String? noStr;
  final String? tail;

  //是否包含输入框
  final bool? isEdit;
  final TextEditingController? controller;

  InfoDialog(
    this.content, {
    Key? key,
    this.yesCallback,
    this.noCallback,
    this.yesStr,
    this.noStr,
    this.name,
    this.tail,
    this.title,
    this.isEdit,
    this.controller,
    this.backCallback,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.transparent,
      child: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Container(
              margin: EdgeInsets.only(left: 20.w, right: 20.w, bottom: 30.w),
              decoration: const BoxDecoration(
                image: DecorationImage(
                  image: AssetImage("assets/auth_fillin_alert.png"),
                  fit: BoxFit.cover,
                ),
              ),
              constraints: BoxConstraints(minHeight: 236.w),
              child: Column(
                mainAxisSize: MainAxisSize.min,
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Container(
                    margin: EdgeInsets.only(bottom: 19.w, top: 34.w),
                    child: Text(
                      title ?? '确定注销账户？',
                      style: TextStyleUtils.style000000(fontSize: 18.sp, fontWeight: FontWeight.w500),
                    ),
                  ),
                  Container(
                    margin: EdgeInsets.symmetric(horizontal: 24.w),
                    child: RichText(
                      textAlign: TextAlign.center,
                      text: TextSpan(
                        children: [
                          TextSpan(
                            text: content,
                            style: TextStyleUtils.style000000(fontSize: 15.sp),
                          ),
                          TextSpan(text: name ?? '', style: TextStyleUtils.styleF65247(fontSize: 14.sp)),
                          TextSpan(
                            text: tail ?? '',
                            style: TextStyleUtils.style4d4d4d(fontSize: 14.sp),
                          ),
                        ],
                      ),
                    ),
                  ),
                  Visibility(
                    visible: isEdit ?? false,
                    child: Container(
                      margin: EdgeInsets.symmetric(horizontal: 24.w),
                      height: 38.w,
                      decoration: BoxDecoration(
                        border: Border.all(color: ColorManager.colorF2F2F2, width: 1.w),
                        borderRadius: BorderRadius.all(Radius.circular(4.w)),
                      ),
                      alignment: Alignment.center,
                      child: TextField(
                        decoration: const InputDecoration(
                            border: OutlineInputBorder(
                              //保证TextField输入内容居中
                              borderSide: BorderSide(
                                color: Colors.transparent,
                              ),
                            ),
                            enabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: Colors.transparent,
                              ),
                            ),
                            disabledBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: Colors.transparent,
                              ),
                            ),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: Colors.transparent,
                              ),
                            ),
                            contentPadding: EdgeInsets.zero),
                        controller: controller,
                        textAlign: TextAlign.center,
                        style: TextStyleUtils.style2A2A2A(),
                      ),
                    ),
                  ),
                  SizedBox(height: 24.w),
                  Container(
                    margin: EdgeInsets.symmetric(horizontal: 24.w),
                    child: InkWell(
                      onTap: () => yesCallback!(),
                      child: Container(
                        height: 40.w,
                        alignment: Alignment.center,
                        decoration: BoxDecoration(
                          color: ColorManager.colorD93C3A,
                          borderRadius: BorderRadius.all(Radius.circular(20.w)),
                        ),
                        child: Text(
                          yesStr ?? '确定',
                          style: TextStyleUtils.styleFFFFFF(
                            fontSize: 16.sp,
                          ),
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ),
            ClickWidget(
              onTap: (){
                backCallback!();
              },
                child: Image.asset(
              'images/auth_alert_close.png',
              width: 20.w,
              height: 20.w,
            ))
          ],
        ),
      ),
    );
  }
}
